package com.rc.saas.mini.service.tenant;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.rc.saas.mini.mapper.tenant.TenantAppUpgradeMapper;
import com.rc.saas.mini.model.tenant.TenantAppUpgrade;
import com.rc.saas.mini.model.tenant.TenantAppUpgradeExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TenantAppUpgradeServiceImpl implements TenantAppUpgradeService {
    @Autowired
    private TenantAppUpgradeMapper tenantAppUpgradeMapper;

    @Override
    public TenantAppUpgradeMapper getMapper() {
        return tenantAppUpgradeMapper;
    }

    @Override
    public PageInfo<TenantAppUpgrade> listPageVersion(String appType, String tenantCode, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        TenantAppUpgradeExample example = new TenantAppUpgradeExample();

        example.createCriteria().andAppTypeEqualTo(appType).andTenantCodeEqualTo(tenantCode).andStatusEqualTo("1");
        example.setOrderByClause(" app_version desc");
        List<TenantAppUpgrade> tenantAppUpgrades = tenantAppUpgradeMapper.selectByExample(example);
        return new PageInfo<>(tenantAppUpgrades);
    }
}
